﻿using System;
using L2NH.Core.Domain;
using L2NH.Core.Presentation;
using L2NH.Infrastructure;
using L2NH.Infrastructure.DataAccess;

namespace L2NH.ConsoleApp
{
   internal class Program
   {
      private static void Main()
      {
         App.Init(new MyAppSettings());

         UnitOfWork.Begin();

         INHibernateDemoPresenter presenter = new NHibernateDemoPresenter(new ConsoleView(), new NHRepository());
         presenter.Demo();

         UnitOfWork.End();
         UnitOfWork.CloseSessionFactory();
      }

      private class ConsoleView : INHibernateDemoView
      {
         public void Display(Employee employee)
         {
            Console.WriteLine(employee.Name);
         }

         public string PromptForLastName()
         {
            Console.Write("Enter partial last name: ");
            return Console.ReadLine();
         }
      }
   }
}